/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import core.AEntityContentProvider;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ivan
 */
@Entity
@Table(name = "TOURNAMENT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tournament.findAll", query = "SELECT t FROM Tournament t"),
    @NamedQuery(name = "Tournament.findByTournamentId", query = "SELECT t FROM Tournament t WHERE t.tournamentId = :tournamentId"),
    @NamedQuery(name = "Tournament.findByName", query = "SELECT t FROM Tournament t WHERE t.name = :name"),
    @NamedQuery(name = "Tournament.findByDateOfInception", query = "SELECT t FROM Tournament t WHERE t.dateOfInception = :dateOfInception"),
    @NamedQuery(name = "Tournament.findByDateOfEnd", query = "SELECT t FROM Tournament t WHERE t.dateOfEnd = :dateOfEnd"),
    @NamedQuery(name = "Tournament.findByStatus", query = "SELECT t FROM Tournament t WHERE t.status = :status"),
    @NamedQuery(name = "Tournament.findByGroupStage", query = "SELECT t FROM Tournament t WHERE t.groupStage = :groupStage"),
    @NamedQuery(name = "Tournament.findByFinalStage", query = "SELECT t FROM Tournament t WHERE t.finalStage = :finalStage"),
    @NamedQuery(name = "Tournament.findByPrize", query = "SELECT t FROM Tournament t WHERE t.prize = :prize")})
public class Tournament extends AEntityContentProvider<Tournament> implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @GeneratedValue(generator="CommonSeq", strategy= GenerationType.SEQUENCE)
   // @SequenceGenerator( name="CommonSeq",sequenceName="common_seq", allocationSize=1)
    @Column(name = "TOURNAMENT_ID")
    private BigDecimal tournamentId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DATE_OF_INCEPTION")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfInception;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DATE_OF_END")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfEnd;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 15)
    @Column(name = "STATUS")
    private String status;
    @Column(name = "GROUP_STAGE")
    private BigInteger groupStage;
    @Column(name = "FINAL_STAGE")
    private BigInteger finalStage;
    @Size(max = 20)
    @Column(name = "PRIZE")
    private String prize;
    @JoinColumn(name = "WINNER_TEAM_ID", referencedColumnName = "TEAM_ID")
    @ManyToOne
    private Team winnerTeamId;
    @JoinColumn(name = "OWNER", referencedColumnName = "SYS_USER_ID")
    @ManyToOne(optional = false)
    private SysUser owner;
    @JoinColumn(name = "LEAGUE_ID", referencedColumnName = "LEAGUE_ID")
    @ManyToOne
    private League leagueId;
    @OneToMany(mappedBy = "tournamentId")
    private Set<Game> gameSet;

    public Tournament() {
    }

    public Tournament(BigDecimal tournamentId) {
        super(Tournament.class);
        this.tournamentId = tournamentId;
    }

    public Tournament(BigDecimal tournamentId, String name, Date dateOfInception, Date dateOfEnd, String status) {
        super(Tournament.class);
        this.tournamentId = tournamentId;
        this.name = name;
        this.dateOfInception = dateOfInception;
        this.dateOfEnd = dateOfEnd;
        this.status = status;
    }

    public BigDecimal getTournamentId() {
        return tournamentId;
    }

    public void setTournamentId(BigDecimal tournamentId) {
        this.tournamentId = tournamentId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getDateOfInception() {
        return dateOfInception;
    }

    public void setDateOfInception(Date dateOfInception) {
        this.dateOfInception = dateOfInception;
    }

    public Date getDateOfEnd() {
        return dateOfEnd;
    }

    public void setDateOfEnd(Date dateOfEnd) {
        this.dateOfEnd = dateOfEnd;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public BigInteger getGroupStage() {
        return groupStage;
    }

    public void setGroupStage(BigInteger groupStage) {
        this.groupStage = groupStage;
    }

    public BigInteger getFinalStage() {
        return finalStage;
    }

    public void setFinalStage(BigInteger finalStage) {
        this.finalStage = finalStage;
    }

    public String getPrize() {
        return prize;
    }

    public void setPrize(String prize) {
        this.prize = prize;
    }

    public Team getWinnerTeamId() {
        return winnerTeamId;
    }

    public void setWinnerTeamId(Team winnerTeamId) {
        this.winnerTeamId = winnerTeamId;
    }

    public SysUser getOwner() {
        return owner;
    }

    public void setOwner(SysUser owner) {
        this.owner = owner;
    }

    public League getLeagueId() {
        return leagueId;
    }

    public void setLeagueId(League leagueId) {
        this.leagueId = leagueId;
    }

    @XmlTransient
    public Set<Game> getGameSet() {
        return gameSet;
    }

    public void setGameSet(Set<Game> gameSet) {
        this.gameSet = gameSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tournamentId != null ? tournamentId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tournament)) {
            return false;
        }
        Tournament other = (Tournament) object;
        if ((this.tournamentId == null && other.tournamentId != null) || (this.tournamentId != null && !this.tournamentId.equals(other.tournamentId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Tournament[ tournamentId=" + tournamentId + " ]";
    }
    
}
